home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dskut / reform16.zip / REFORMAT.IN3 < prev    next >
Text File  |  1990-03-03  |  7KB  |  160 lines

  1. {REFORMAT.IN3, aka FRAMER.INC }
  2. {PC-specific direct screen writing to create frames.
  3.  There are lots of examples on how to do this with Turbo and
  4.  regular "Write" if you have an odd video setup.
  5.  We make no effort to reduce "flicker" on slow or color
  6.  screens, since this is not a video-oriented utility.
  7.  Toad Hall.
  8. }
  9.  
  10. TYPE
  11.   Win_Set_Info
  12.     = RECORD
  13.         x,len,y,ht : Byte;
  14.       END;
  15.  
  16.   Window_Array  = ARRAY [0..2]
  17.                     OF Win_Set_Info;
  18. CONST
  19. win_set : Window_Array =  (
  20.            {      x  w  y  h }
  21.            {0}  ( x: 1; len:79; y: 1; ht:24),
  22.            {1}  ( x: 2; len:77; y:17; ht: 2),
  23.            {2}  ( x: 1; len:79; y: 2; ht:20)
  24.            );
  25.  
  26. VAR
  27.   color,
  28.   wLeft,wTop,
  29.   width,height,
  30.   ToadY        : INTEGER;
  31.  
  32. PROCEDURE Frame(windnr : INTEGER);
  33.   BEGIN
  34. { window stack:
  35.    0[win_set] = inner left edge of target window
  36.    1[win_set] = length of target window
  37.    2[win_set] = inner top edge of target window
  38.    3[win_set] = height of target window
  39. }
  40.  
  41. Inline(
  42.   $B4/$0F/       {   mov     AH,$0F     ;get current video mode}
  43.   $CD/$10/       {   int     $10}
  44.   $3C/$07/       {   cmp     al,7       ;mono?}
  45.   $B8/$00/$B0/   {   mov     AX,$B000   ;assume mono}
  46.   $74/$02/       {   je      S1         ; yep}
  47.   $B4/$B8/       {    mov    ah,$B8     ; nope, color}
  48.                  {S1:}
  49.   $8E/$C0/       {   mov     ES,AX      ;ES=video memory}
  50.                  
  51.   $BE/>WIN_SET/  {   mov     si,>win_set;base of window array}
  52.   $8B/$86/>WINDNR/ {   mov     AX,>windnr[BP] ;the window number parm}
  53.   $09/$C0/       {   or      AX,AX      ;0?}
  54.   $74/$06/       {   je      S2         ; yep}
  55.                  {;    mov    bl,4      ;size of a window array}
  56.                  {;    mul    BL        ;get offset in array 0..10}
  57.   $D1/$E0/       {    shl    ax,1       ;get offset in array 0..10}
  58.   $D1/$E0/       {    shl    ax,1       ;(same as * 4)}
  59.   $01/$C6/       {    add    SI,AX      ;DS:SI=window[wind_nr]}
  60.                  {S2:}
  61.   $8B/$04/       {   mov     AX,[SI]    ;AL=left edge, AH=width}
  62.   $88/$E2/       {   mov     DL,AH      ;keep width in DL}
  63.   $A2/>WLEFT/    {   mov     [>wLeft],AL;save in global}
  64.                  
  65.   $8B/$44/$02/   {   mov     AX,2[SI]   ;AL=top edge,AH=height}
  66.   $88/$E6/       {   mov     DH,AH      ;keep height in DH}
  67.                  
  68.                  {;find starting address of window}
  69.   $31/$C0/       {   xor     AX,AX      ;clear msb}
  70.   $89/$C3/       {   mov     BX,AX}
  71.   $8A/$44/$02/   {   mov     al,2[SI]   ; top edge}
  72.   $48/           {   dec     AX}
  73.   $A2/>WTOP/     {   mov     [>wTop],AL ;save in global}
  74.                  
  75.                  {;  mov     bl,160     ;ax = top_edge*160 + lf_edge*2}
  76.                  {;  mul     bl}
  77.   $B9/$A0/$00/   {   mov     cx,160     ;handy constant, msb 0}
  78.   $F6/$E1/       {   mul     cl         ;ax = top_edge*160 + lf_edge*2}
  79.   $8A/$1C/       {   mov     bl,[SI]    ;left edge}
  80.   $4B/           {   dec     BX}
  81.   $D1/$E3/       {   shl     BX,1}
  82.   $00/$D8/       {   add     al,bl}
  83.   $80/$D4/$00/   {   adc     ah,0}
  84.   $89/$C7/       {   mov     DI,ax      ;ES:DI= top left corner}
  85.   $57/           {   PUSH    DI         ;save for drawing verticals}
  86.                  {;find distance to bottom line of window}
  87.   $31/$C0/       {   xor     AX,AX      ;clear msb}
  88.                  {;  mov     BX,AX}
  89.   $88/$F0/       {   mov     al,DH      ; DH=height}
  90.                  {;  mov     bl,160     ; ax = wd_height*160}
  91.                  {;  mul     bl}
  92.   $F6/$E1/       {   mul     cl         ;ax = wd_height*160}
  93.   $89/$C3/       {   mov     bx,ax      ;BX=offset to bottom left}
  94.                  
  95.   $8A/$26/>COLOR/ {   mov     AH,[>color];get color back}
  96.   $B0/$C8/       {   mov     AL,$0C8    ;bottom left corner}
  97.   $26/           {   ES:}
  98.   $89/$01/       {   mov     [DI+BX],AX ;bottom left}
  99.   $B0/$C9/       {   mov     AL,$0C9    ;top left corner,}
  100.   $AB/           {   stosw              ;stuff, bump to next scr word}
  101.                  
  102.   $88/$D1/       {   mov     cl,DL      ; get width of window, minus 2}
  103.   $49/           {   dec     cx         ;(msb already 0)}
  104.   $B0/$CD/       {   mov     al,$0CD    ; get horizontal line into ax}
  105.   $50/           {   push    AX         ;save for bottom}
  106.                  
  107.                  {;draw the 2 horizontals}
  108.   $57/           {   PUSH    DI         ;ES:DI = top left corner+1}
  109.   $51/           {   PUSH    CX}
  110.   $F2/$AB/       {   rep  stosw}
  111.   $B0/$BB/       {   mov     al,$0BB    ; top right corner}
  112.   $26/           {   ES:}
  113.   $89/$05/       {   mov     [DI],AX}
  114.   $59/           {   POP     CX}
  115.   $5F/           {   POP     DI         ;ES:DI=top left corner+1}
  116.                  
  117.   $58/           {   pop     AX         ;horizontal line char}
  118.   $01/$DF/       {   add     DI,BX      ;now at bottom left+1}
  119.   $F2/$AB/       {   rep  stosw}
  120.                  
  121.   $B0/$BC/       {   mov     al,$0BC    ; bottom right corner}
  122.   $26/           {   ES:}
  123.   $89/$05/       {   mov     [DI],ax}
  124.                  
  125.   $5F/           {   POP     DI         ;get back window starting}
  126.                  {                      ;address}
  127.   $88/$D3/       {   mov     bl,DL      ;get width of window minus 1}
  128.                  {                      ;into bx}
  129.   $30/$FF/       {   xor     bh,bh}
  130.   $D1/$E3/       {   shl     bx,1}
  131.   $81/$C7/$A0/$00/ {   add     DI,160     ; move down a line (don't}
  132.                  {                      ; overwrite corners)}
  133.   $88/$F1/       {   mov     cl,DH      ; get height of window, minus}
  134.                  {                      ; 2, into cx}
  135.   $30/$ED/       {   xor     ch,ch}
  136.   $49/           {   dec     cx}
  137.   $B0/$BA/       {   mov     al,$0BA    ; get vertical line into al}
  138.                  {;draw the two verticals}
  139.                  {V1:}
  140.   $26/           {   ES:}
  141.   $89/$05/       {   mov     [DI],ax    ;left side}
  142.   $26/           {   ES:}
  143.   $89/$01/       {   mov     [DI+BX],ax ;right side}
  144.   $81/$C7/$A0/$00/ {   add     DI,160     ;next row}
  145.   $E2/$F4/       {   loop    V1}
  146.  
  147.   $31/$C0/       {   xor     AX,AX      ;clear msb}
  148.   $88/$D0/       {   mov     AL,DL}
  149.   $48/           {   dec     AX}
  150.   $48/           {   dec     ax}
  151.   $A3/>WIDTH/    {   mov     [>width],AX}
  152.   $31/$C0/       {   xor     AX,AX      ;clear msb}
  153.   $88/$F0/       {   mov     AL,DH}
  154.   $48/           {   dec     AX}
  155.   $A3/>HEIGHT/   {   mov     [>height],AX}
  156.   $B8/$01/$00/   {   mov     ax,1}
  157.   $A3/>TOADY);   {   mov     [>ToadY],ax ;reset ToadY to 1}
  158.  
  159. END;  {of Frame}
  160.